package com.origin.src.aware;

import com.origin.src.XBeanA;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

@Component("xAware")
@Primary
public class XAware
//{
        implements BeanFactoryAware {

    public XBeanA beanA;


    public XAware xAware;

    @Autowired
    public void setxAware(XAware xAware) {
        this.xAware = xAware;
    }

    @Autowired
    public void setBeanA(XBeanA beanA) {
        this.beanA = beanA;
    }


    static int i = 0;

    @Autowired
    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        i++;
        StackTraceElement[] ss = Thread.currentThread().getStackTrace();
        System.out.println("--->调用BeanFactoryAware setBeanFactory次：" + i);

    }
}
